/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package cn.knet.sp.ncrm.modules.mywork.aftersalesservice.web;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.knet.sp.ncrm.common.persistence.Page;
import cn.knet.sp.ncrm.common.utils.DateUtils;
import cn.knet.sp.ncrm.common.web.BaseController;
import cn.knet.sp.ncrm.modules.customer.aftersalesservice.entity.PotentialAfterSalesService;
import cn.knet.sp.ncrm.modules.customer.aftersalesservice.service.PotentialAfterSalesServiceService;


/**
 * 个人成单信息展示
 * @author zhangbin
 * @version 2015 /09/14 16:20:31
 */
@Controller
@RequestMapping(value = "${adminPath}/mywork/afterSales")
public class MyAfterSalesController extends BaseController {

	@Autowired
	private PotentialAfterSalesServiceService potentialAfterSalesServiceService;
	
	@RequiresPermissions("user")
	@RequestMapping(value = {"list",""})
	public String listOnShow() {
		return "modules/mywork/aftersale/show";
	}


	@RequiresPermissions("user")
	@RequestMapping(value = "listOnShowDate")
	@ResponseBody
	public Page<PotentialAfterSalesService> listOnShowDate(PotentialAfterSalesService potentialAfterSalesService, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<PotentialAfterSalesService> page = new Page<PotentialAfterSalesService>(request, response);
		if(potentialAfterSalesService!=null){
			if(potentialAfterSalesService.getEndDate()!=null){
				potentialAfterSalesService.setEndDate(DateUtils.addMilliseconds(potentialAfterSalesService.getEndDate(), DateUtils.TIME_23_59_50));
			}
			potentialAfterSalesService.setOnshow("1"); //固定为展示信息
			page = potentialAfterSalesServiceService.findPage(page, potentialAfterSalesService);
		}else{
			return null;
		}
		return page;
	}
}